package com.lzw.service.impl.dormitoryAdmin;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lzw.mapper.dormitoryAdmin.LeaveRecordMapper;
import com.lzw.pojo.LeaveRecord;
import com.lzw.service.dormitoryAdmin.LeaveRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;

@Service
public class LeaveRecordServiceImpl implements LeaveRecordService {

    @Autowired
    private LeaveRecordMapper leaveRecordMapper;

    @Override
    public List<LeaveRecord> list(Integer pageNum, Integer pageSize, LocalDate startDate, LocalDate endDate) {
        PageHelper.startPage(pageNum,pageSize);
        List<LeaveRecord> list = leaveRecordMapper.list(startDate,endDate);
        Page<LeaveRecord> leaveRecords = (Page<LeaveRecord>) list;
        return leaveRecords;
    }

    @Override
    public void update(LeaveRecord leaveRecord) {
        leaveRecordMapper.update(leaveRecord);
    }

    @Override
    public void delete(List<Integer> ids) {
        leaveRecordMapper.delete(ids);
    }

    @Override
    public LeaveRecord getById(Integer id) {
        return leaveRecordMapper.getById(id);
    }
}
